<?php

/**
 * 
 * @author guibinyu
 * @date 2017-06-15 04:14:50
 */
class Template   
{
    
   private $params;
   private $Wechat;
   public function __construct($Wechat)
    {
        $this->Wechat = $Wechat;
    }
    /**
     * 模板消息,设置所属行业
     */
    public function setIndustry()
    {
        $data = isset($_POST['param']) && !empty($_POST['param']) ? json_decode($_POST['param'],true) : array(
            'industry_id1'=>1,
            'industry_id2'=>4,
        );
        $result = $this->Wechat->template->setIndustry($data);
        return $result;
    }
     /**
     * 添加消息模板
     */
    public function addMessage()
    {
        $data = isset($_POST['param']) && !empty($_POST['param']) ? json_decode($_POST['param'],true) : array('template_id_short' => 'TM00015');
        $result = $this->Wechat->template->addMessage($data);
        return $result;
    }
     /**
     * 发送模板消息
     */
    public function sendMessage()
    {
        $data = isset($_POST['param']) && !empty($_POST['param']) ? json_decode($_POST['param'],true) : array(
            'touser' => 'oYVyYw2BzLX8eJ1I-oCDSN6z4avI',
            'template_id' => 'Zx-REWtsUGEdSZcmXhso9OKhieCwguItXXGw-rHv16c',
            'url' => 'http://www.baidu.com',
            'data' => array(
                'first' => array(
                    'value' => '恭喜你购买成功',
                    'color' => '#173177',
                )
            )
        );
        $result = $this->Wechat->template->sendMessage($data);
       return $result;
    }
    public function __call($name, $arguments)
    {
        exit("Test does not have [{$name}] method !");
    }
     
//index, view, create, update, delete, options
}